VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmRegistry 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "SendKey Settings"
   ClientHeight    =   4395
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6810
   Icon            =   "Registry.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4395
   ScaleWidth      =   6810
   StartUpPosition =   2  'CenterScreen
   Begin TabDlg.SSTab SSTab1 
      Height          =   3765
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   6765
      _ExtentX        =   11933
      _ExtentY        =   6641
      _Version        =   393216
      Tabs            =   2
      TabsPerRow      =   2
      TabHeight       =   520
      TabCaption(0)   =   "Local Settings"
      TabPicture(0)   =   "Registry.frx":0442
      Tab(0).ControlEnabled=   -1  'True
      Tab(0).Control(0)=   "fraFileOptions"
      Tab(0).Control(0).Enabled=   0   'False
      Tab(0).Control(1)=   "cdmOk"
      Tab(0).Control(1).Enabled=   0   'False
      Tab(0).ControlCount=   2
      TabCaption(1)   =   "Destinations"
      TabPicture(1)   =   "Registry.frx":045E
      Tab(1).ControlEnabled=   0   'False
      Tab(1).Control(0)=   "cmdRemove"
      Tab(1).Control(1)=   "cmdAdd"
      Tab(1).Control(2)=   "fraSettings"
      Tab(1).ControlCount=   3
      Begin VB.CommandButton cmdRemove 
         Caption         =   "&Remove"
         Height          =   435
         Left            =   -69660
         TabIndex        =   27
         Top             =   3120
         Width           =   1170
      End
      Begin VB.CommandButton cmdAdd 
         Caption         =   "&Save"
         Default         =   -1  'True
         Height          =   435
         Left            =   -70905
         TabIndex        =   26
         Top             =   3135
         Width           =   1170
      End
      Begin VB.Frame fraSettings 
         Caption         =   "Destinations"
         Height          =   2310
         Left            =   -74865
         TabIndex        =   12
         Top             =   540
         Width           =   6465
         Begin VB.OptionButton optFTP 
            Caption         =   "&FTP"
            Height          =   255
            Left            =   5640
            TabIndex        =   25
            Top             =   1800
            Width           =   615
         End
         Begin VB.OptionButton optCopy 
            Caption         =   "&C&opy"
            Height          =   255
            Left            =   4800
            TabIndex        =   24
            Top             =   1800
            Value           =   -1  'True
            Width           =   735
         End
         Begin VB.CheckBox chkCompress 
            Caption         =   "&Compress"
            Height          =   255
            Left            =   1440
            TabIndex        =   23
            Top             =   1800
            Width           =   1095
         End
         Begin VB.TextBox txtUserName 
            Height          =   315
            Left            =   1380
            TabIndex        =   20
            Top             =   1290
            Width           =   1815
         End
         Begin VB.TextBox txtPassword 
            Height          =   315
            IMEMode         =   3  'DISABLE
            Left            =   4605
            PasswordChar    =   "*"
            TabIndex        =   22
            Top             =   1230
            Width           =   1695
         End
         Begin VB.TextBox txtPhoneEntry 
            Height          =   315
            Left            =   4605
            TabIndex        =   18
            Top             =   825
            Width           =   1695
         End
         Begin VB.TextBox txtShareName 
            Height          =   315
            Left            =   1380
            TabIndex        =   16
            Top             =   855
            Width           =   1815
         End
         Begin VB.ComboBox cboDest 
            Height          =   315
            Left            =   1380
            TabIndex        =   14
            Top             =   345
            Width           =   1875
         End
         Begin VB.Label Label1 
            Caption         =   "Destination:"
            Height          =   285
            Left            =   255
            TabIndex        =   13
            Top             =   345
            Width           =   1140
         End
         Begin VB.Label lblUserName 
            Caption         =   "User Name:"
            Height          =   195
            Left            =   255
            TabIndex        =   19
            Top             =   1320
            Width           =   915
         End
         Begin VB.Label lblPassword 
            Caption         =   "Password:"
            Height          =   195
            Left            =   3600
            TabIndex        =   21
            Top             =   1335
            Width           =   855
         End
         Begin VB.Label lblPhoneEntry 
            Caption         =   "Phone Entry:"
            Height          =   255
            Left            =   3540
            TabIndex        =   17
            Top             =   840
            Width           =   915
         End
         Begin VB.Label lblShareName 
            Caption         =   "Share Name:"
            Height          =   255
            Left            =   255
            TabIndex        =   15
            Top             =   870
            Width           =   975
         End
      End
      Begin VB.CommandButton cdmOk 
         Caption         =   "&Ok"
         Height          =   435
         Left            =   5385
         TabIndex        =   11
         Top             =   3165
         Width           =   1170
      End
      Begin VB.Frame fraFileOptions 
         Caption         =   "Local Settings"
         Height          =   2640
         Left            =   180
         TabIndex        =   1
         Top             =   435
         Width           =   6450
         Begin VB.Frame fraDeleteFiles 
            Height          =   855
            Left            =   210
            TabIndex        =   28
            Top             =   1455
            Width           =   6150
            Begin VB.CheckBox chkDeleteFiles 
               Caption         =   "Delete Source Files?"
               Height          =   255
               Left            =   120
               TabIndex        =   7
               Top             =   0
               Width           =   1860
            End
            Begin VB.TextBox txtMoveToFolder 
               Height          =   315
               Left            =   1470
               TabIndex        =   9
               Top             =   360
               Width           =   3915
            End
            Begin VB.CommandButton cmdSearch 
               Height          =   315
               Left            =   5565
               Picture         =   "Registry.frx":047A
               Style           =   1  'Graphical
               TabIndex        =   10
               Top             =   315
               Width           =   435
            End
            Begin VB.Label lblMoveFolder 
               Caption         =   "Move to Folder:"
               Height          =   255
               Left            =   210
               TabIndex        =   8
               Top             =   420
               Width           =   1275
            End
         End
         Begin VB.TextBox txtLogFileFolder 
            Height          =   315
            Left            =   1710
            TabIndex        =   5
            Top             =   930
            Width           =   3900
         End
         Begin VB.CommandButton cmdSearchs 
            Height          =   330
            Left            =   5805
            Picture         =   "Registry.frx":0804
            Style           =   1  'Graphical
            TabIndex        =   6
            Top             =   930
            Width           =   435
         End
         Begin VB.TextBox txtBranchCode 
            Height          =   315
            Left            =   1695
            TabIndex        =   3
            Top             =   465
            Width           =   1575
         End
         Begin VB.Label lblLogFileFolder 
            Caption         =   "Log File Folder:"
            Height          =   255
            Left            =   240
            TabIndex        =   4
            Top             =   930
            Width           =   1155
         End
         Begin VB.Label lblBranchCode 
            Caption         =   "Branch Code:"
            Height          =   255
            Left            =   270
            TabIndex        =   2
            Top             =   495
            Width           =   1215
         End
      End
   End
   Begin VB.CommandButton cmdExit 
      Cancel          =   -1  'True
      Caption         =   "E&xit"
      Height          =   435
      Left            =   5550
      TabIndex        =   29
      Top             =   3885
      Width           =   1170
   End
End
Attribute VB_Name = "frmRegistry"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub cboDest_Change()
    
    Dim strReg As clsOptions
    Dim strDelete As String
    
    Set strReg = New clsOptions
    
    If cboDest.Text <> "" Then
        txtUserName.Text = strReg.UserName(cboDest.Text)
        txtPassword.Text = strReg.Password(cboDest.Text)
        txtPhoneEntry.Text = strReg.PhoneEntry(cboDest.Text)
        txtShareName.Text = strReg.ShareName(cboDest.Text)
        If strReg.Compress(cboDest.Text) = "Yes" Then
          chkCompress.Value = 1
        Else
          chkCompress.Value = 0
        End If
        If strReg.Transfer(cboDest.Text) = "FTP" Then
          optFTP.Value = True
        Else
          optCopy.Value = True
        End If
    Else
        txtUserName.Text = ""
        txtPassword.Text = ""
        txtPhoneEntry.Text = ""
        txtShareName.Text = ""
        chkCompress.Value = False
        optCopy.Value = True
    End If
    
    Set strReg = Nothing

End Sub

Private Sub cboDest_Click()

    Dim strReg As clsOptions
    Dim strDelete As String
    
    Set strReg = New clsOptions
    
    If cboDest.Text <> "" Then
        txtUserName.Text = strReg.UserName(cboDest.Text)
        txtPassword.Text = strReg.Password(cboDest.Text)
        txtPhoneEntry.Text = strReg.PhoneEntry(cboDest.Text)
        txtShareName.Text = strReg.ShareName(cboDest.Text)
        If strReg.Compress(cboDest.Text) = "Yes" Then
          chkCompress.Value = 1
        Else
          chkCompress.Value = 0
        End If
        If strReg.Transfer(cboDest.Text) = "FTP" Then
          optFTP.Value = True
        Else
          optCopy.Value = True
        End If
    Else
        txtUserName.Text = ""
        txtPassword.Text = ""
        txtPhoneEntry.Text = ""
        txtShareName.Text = ""
        chkCompress.Value = False
        optCopy.Value = True
    End If
    
    Set strReg = Nothing

End Sub

Private Sub cdmOk_Click()

Dim strReg As clsOptions
Dim strDestinationCode As String

Set strReg = New clsOptions

If txtBranchCode.Text = "" Then
    strReg.BranchCode = txtBranchCode.Text
Else
    strReg.BranchCode = txtBranchCode.Text
End If
strBranchCode = strReg.BranchCode

If txtLogFileFolder.Text = "" Then
    strReg.LogFolder = " "
Else
    strReg.LogFolder = txtLogFileFolder.Text
End If

If chkDeleteFiles.Value = 1 Then
    strReg.DeleteFiles = "Yes"
    strReg.MoveFolder = ""
ElseIf chkDeleteFiles.Value = 0 Then
    strReg.DeleteFiles = "No"
    If txtMoveToFolder.Text = "" Then
        strReg.MoveFolder = " "
    Else
        strReg.MoveFolder = txtMoveToFolder.Text
    End If
End If

Set strReg = Nothing

Unload Me

End Sub

Private Sub chkDeleteFiles_Click()
If chkDeleteFiles.Value = 1 Then
    lblMoveFolder.Enabled = False
    txtMoveToFolder.Enabled = False
    cmdSearch.Enabled = False
ElseIf chkDeleteFiles.Value = 0 Then
    lblMoveFolder.Enabled = True
    txtMoveToFolder.Enabled = True
    cmdSearch.Enabled = True
End If
End Sub

Private Sub cmdCancel_Click()
  End
End Sub

Private Sub cmdAdd_Click()

  'add a destination to the registry
  If cboDest.Text <> "" Then
    CreateNewDestination
    PopulateDestinations
  End If

End Sub

Private Sub cmdExit_Click()
    Unload frmRegistry
End Sub

Private Sub cmdRemove_Click()

  'remove the currently selected destination from the registry
  If cboDest.Text <> "" Then
    KillDestination cboDest.Text
    PopulateDestinations
  End If
  
End Sub

Private Sub cmdSearch_Click()
    strType = 2
    SetWindowPos frmSetPath.hWnd, HWND_TOPMOST, 10, 10, 10, 10, SWP_NOMOVE Or SWP_NOSIZE
    frmSetPath.Show vbModal
End Sub

Private Sub cmdSearchs_Click()
    strType = 1
    SetWindowPos frmSetPath.hWnd, HWND_TOPMOST, 10, 10, 10, 10, SWP_NOMOVE Or SWP_NOSIZE
    frmSetPath.Show vbModal
End Sub

Private Sub Form_Activate()
  txtUserName.SetFocus
End Sub

Private Sub Form_Load()

    Dim strReg As clsOptions
    Dim strDestinationCode As String
    Dim strDelete As String
    Dim XML As clsXML
    
    Set strReg = New clsOptions
    
    PopulateDestinations
    
    'filling the info from the registry into the form
    txtBranchCode.Text = strReg.BranchCode
    strBranchCode = strReg.BranchCode
    strDelete = strReg.DeleteFiles
    If strDelete <> "" Then
        If strDelete = "Yes" Then
            chkDeleteFiles.Value = 1
        Else
            chkDeleteFiles.Value = 0
        End If
    End If
    txtMoveToFolder.Text = strReg.MoveFolder
    txtLogFileFolder.Text = strReg.LogFolder
    
    Set strReg = Nothing

End Sub

Private Sub PopulateDestinations()
    
    Dim strReg As clsOptions
    Dim strNodeList As String
    Dim arrDestinationList() As String
    Dim lngArrayLen As Long
    Dim i As Long
    
    Set strReg = New clsOptions
    
    'clear the list
    cboDest.Clear
    
    'pick up all the destinations from the registry node
    strNodeList = strReg.GetAllDestinationsFromReg
    
    'the frunction GetAllDestinationsFromReg returns a
    arrDestinationList = Split(strNodeList, ",", -1, vbTextCompare)
    lngArrayLen = UBound(arrDestinationList)
    For i = 0 To lngArrayLen
        cboDest.AddItem arrDestinationList(i)
    Next
      
    'Reset the form
    txtUserName.Text = ""
    txtPassword.Text = ""
    txtPhoneEntry.Text = ""
    txtShareName.Text = ""
    chkCompress.Value = False
    optCopy.Value = True
    cboDest.Text = ""
    
    Set strReg = Nothing

End Sub

Private Sub CreateNewDestination()

    Dim strReg As clsOptions
    Dim strDestinationCode As String
    Dim strDelete As String

    'this sub will create a new destination in the registry with all the corresponding info
    
    Set strReg = New clsOptions
    strDestinationCode = cboDest.Text
    
    If txtUserName.Text = "" Then
        strReg.UserName(strDestinationCode) = " "
    Else
        strReg.UserName(strDestinationCode) = txtUserName.Text
    End If
    
    If txtPassword.Text = "" Then
        strReg.Password(strDestinationCode) = " "
    Else
        strReg.Password(strDestinationCode) = txtPassword.Text
    End If
    
    If txtPhoneEntry.Text = "" Then
        strReg.PhoneEntry(strDestinationCode) = " "
    Else
        strReg.PhoneEntry(strDestinationCode) = txtPhoneEntry.Text
    End If
    
    If txtShareName.Text = "" Then
        strReg.ShareName(strDestinationCode) = " "
    Else
        strReg.ShareName(strDestinationCode) = txtShareName.Text
    End If
    
    If chkCompress.Value = 1 Then
        strReg.Compress(strDestinationCode) = "Yes"
    Else
        strReg.Compress(strDestinationCode) = "No"
    End If
    
    If optCopy.Value = True Then
        strReg.Transfer(strDestinationCode) = "Copy"
    Else
        strReg.Transfer(strDestinationCode) = "FTP"
    End If
    
End Sub

Private Sub KillDestination(ByVal strDest As String)

    Dim lngDeleteReturn As Long
    Dim hKey As Long
    Dim lpSubKey As String
    Dim lngRetVal As Long
    Dim i As Long
    
    'DELETE THE KEY FROM THE REGISTRY
    lngDeleteReturn = RegDeleteKey(HKEY_LOCAL_MACHINE, "Software\Mindkey Software Solutions\SendKey\Destinations\" & strDest)
    
End Sub
